package state;

import javax.microedition.lcdui.Font;

public class Graphics {
  public static final int TOP = javax.microedition.lcdui.Graphics.TOP;

  public static final int LEFT = javax.microedition.lcdui.Graphics.LEFT;

  public static final int RIGHT = javax.microedition.lcdui.Graphics.RIGHT;

  public static final int HCENTER = javax.microedition.lcdui.Graphics.HCENTER;

  public static final int BOTTOM = javax.microedition.lcdui.Graphics.BOTTOM;

  public static final int VCENTER = javax.microedition.lcdui.Graphics.VCENTER;

  public static final int BASELINE = javax.microedition.lcdui.Graphics.BASELINE;
  
  private javax.microedition.lcdui.Graphics g;
  
  public Graphics(javax.microedition.lcdui.Graphics g) {
    this.g = g;
  }

  public void setColor(int RGB) {
    g.setColor(RGB);
  }

  public void fillRect(int x, int y, int width, int height) {
    g.fillRect(x, y, width, height);
  }

  public void drawImage(Image image, int x, int y, int anchor) {
    if (image!= null) {
      if (image.getImage() != null) {
        g.drawImage(image.getImage(), x, y, anchor);
        image.setLastTimeUse(System.currentTimeMillis());
      } else {
        if (System.currentTimeMillis() - image.getLastTimeUse() > ResourceManager.RESOURCE_IDLE_TIME) {
          ResourceManager.requestResource(image.getCategory(), image.getName());
          image.setLastTimeUse(System.currentTimeMillis());
        }
      }
    }
  }

  public void drawString(String text, int x, int y, int anchor) {
    g.drawString(text, x, y, anchor);
  }

  public void setFont(Font font) {
    g.setFont(font);
  }

  public void setClip(int x, int y, int width, int height) {
    g.setClip(x, y, width, height);
  }

  public int getColor() {
    return g.getColor();
  }

  public void drawLine(int x1, int y1, int x2, int y2) {
    g.drawLine(x1, y1, x2, y2);
  }

  public int getClipX() {
    return g.getClipX();
  }

  public int getClipWidth() {
    return g.getClipWidth();
  }

  public int getClipY() {
    return g.getClipY();
  }

  public int getClipHeight() {
    return g.getClipHeight();
  }

  public void clipRect(int x, int y, int width, int height) {
    g.clipRect(x, y, width, height);
  }
  
  public void drawRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height, boolean processAlpha) {
    g.drawRGB(rgbData, offset, scanlength, x, y, width, height, processAlpha);
  }

  public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
    g.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
  }

  public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
    g.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
  }

  public void drawRect(int x, int y, int width, int height) {
    g.drawRect(x, y, width, height);
  }
}
